#!/bin/bash

latest=2022.2.2
latestcommit=4d3b4271208b8018b89d1125c5e16a7535e1feb7

if [ -z "$1" ]
then
  echo -e "\033[31m未指定版本\033[0m"
  echo -e "\033[35m开始打包最新版本 >>> $latest\033[0m"
  git reset --hard $latestcommit
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
elif [ "$1" == "$latest" ]
then
  echo -e "\033[35m开始打包指定版本 >>> $latest\033[0m"
  git reset --hard $latestcommit
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
elif [ "$1" == "2022.2.2" ]
then
  echo -e "\033[35m开始打包指定版本 >>> 2022.2.2\033[0m"
  git reset --hard 4d3b4271208b8018b89d1125c5e16a7535e1feb7
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
elif [ "$1" == "2022.1.1" ]
then
  echo -e "\033[35m开始打包指定版本 >>> 2022.1.1\033[0m"
  git reset --hard 221bf8800e7e09534eb1e7f6d2e71c64e7274bf6
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
elif [ "$1" == "2021.0.1" ]
then
  echo -e "\033[35m开始打包指定版本 >>> 2021.0.1\033[0m"
  git reset --hard 37b202d5f9141255cd3b2f6c59486548bae40254
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
else
  echo -e "\033[31m无指定版本\033[0m"
  echo -e "\033[35m开始打包最新版本 >>> $latest\033[0m"
  git reset --hard $latestcommit
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
fi
